home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / dcom / modems-part1 / 2544 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  11.2 KB

  1. Path: mips.pfalz.de!not-for-mail
  2. From: naddy@mips.pfalz.de (Christian Weisgerber)
  3. Newsgroups: comp.dcom.modems
  4. Subject: Re: USR - a PC modem company
  5. Date: 22 Jan 1996 15:54:14 +0100
  6. Message-ID: <4e08em$ida@mips.pfalz.de>
  7. References: <4d0urh$8rg@usenety1.news.prodigy.com> <DKzK41.E2@lazrus.cca.rockwell.com> <DL068x.IBy@freenet.carleton.ca> <4der33$e7e@usenety1.news.prodigy.com>
  8. NNTP-Posting-Host: mips.pfalz.de
  9.  
  10. davidsen@tmr.com (bill davidsen) writes:
  11.  
  12. > All I want is a way to do it myself, unless it's totally arcane it
  13. > would be a nice thing for someone to post to the net. Assuming that
  14. > USR has a protocol spec for this.
  15. > Want to send me a copy, USR?
  16.  
  17. Here's something I found in my mailbox one day. Translated from German
  18. by yours truly, original text available on request.
  19.  
  20. --------------->
  21.  
  22. Flash ROM Programming of the new USR Courier Modems
  23. ---------------------------------------------------
  24.  
  25. Note: Do not try anything described in this text without having a
  26.       working SDL.EXE at hand. Any error at an arbitrary stage can
  27.       result in erasure of the flash ROM.
  28.  
  29. Before you can feed new data to the flash ROM you will have to get
  30. in touch with your modem. For this purpose use the undocumented
  31. ^BE^GHmX^I^H command:
  32.  
  33. 1. Send the character sequence
  34.  
  35.         AT^BE^GHmX^I^H
  36.  
  37.    to the modem, where ^ marks a control character (so it is ten
  38.    characters altogether), *without* a terminating carriage
  39.    return. The modem acknowledges this with the character 3Fh,
  40.    E3h, or E4h. A look at the modem shows something happening: the
  41.    MR LED is off now. You have ten seconds to perform steps (2)
  42.    through (4). If nothing has happened by then the modem will
  43.    assume a timeout and return to normal operations.
  44.  
  45. 2. The echo-safe echo test.
  46.  
  47.    To ensure that no hacker is listening in and recording the
  48.    programming sequence, both computer and modem then change the
  49.    bitrate twice. First, switch to 19200bps and send a 'Q' to the
  50.    modem. Wait about 100ms, flush the input buffer, switch to
  51.    9600bps, and--ho!--the 'Q' sent at 19200bps will be returned at
  52.    9600bps.
  53.  
  54. 3. Immediately afterwards the original bit rate is restored. The
  55.    modem sends four additional bytes to the computer. Assuming a
  56.    Dual Standard V.34 Ready they are as follows:
  57.  
  58.       00h  Country code. SDL.EXE uses this to ensure that the bad
  59.            guys do not upload the American firmware to a PTT-
  60.            approved modem. 00h or E2h mean North America.
  61.            (Possibly only one of these means North America and the
  62.            other one "any country".)
  63.  
  64.       0Dh  Modem type. #13 is a Courier Dual Standard V.34 Ready.
  65.            The same firmware can also be loaded into modem types
  66.            2, 5, 9, or 12.
  67.  
  68.       00h  This must be zero. Conceivably, this is the version
  69.            number of the firmware programming scheme.
  70.  
  71.       00h  (Reserved; currently no meaning.)
  72.  
  73. 4. The next byte tells the modem how many 128k-banks of the flash
  74.    ROM to erase:
  75.  
  76.       00h  Nothing is erased at all. Can be used to abort the
  77.            operation in case a problem has occured.
  78.  
  79.       02h  The range C0000-FFFFF is erased (for transfer of old
  80.            pre-V.34 firmware or a new loader).
  81.  
  82.       04h  All of the ROM, 80000-FFFFF, is erased (for transfer of
  83.            V.34 firmware).
  84.  
  85.    Subsequently a 2-byte checksum is transmitted which will be
  86.    required for step (7) (see below). The algorithm to calculate
  87.    this checksum will be described below. The checksums for the
  88.    SDL releases available at the time of writing are:
  89.  
  90.      SDL 17.06.94 (firmware)    0Bh / 11h
  91.      SDL 17.08.94 (firmware)    FBh / E1h
  92.                   (loader)      49h / E8h
  93.  
  94.    If you have sent 00h to abort the operation a 2-byte dummy
  95.    checksum must still be appended.
  96.  
  97.    The modem acknowledges the erasure command with 15h.
  98.    (Details on the loader: see the section after the next one.)
  99.  
  100. 5. The modem now attemps to clear the specified ROM range and
  101.    returns the result of the operation:
  102.  
  103.       16h  =  erasure complete
  104.       1Bh  =  block erase error
  105.       1Dh  =  bad programming voltage
  106.  
  107. 6. After successful erasure the ROM can be reprogrammed. This is
  108.    accomplished by simply transmitting all of the new ROM image en
  109.    bloc to the modem, using XON/XOFF flow control.
  110.  
  111.    If the programming has been successful, the modem will return
  112.    14h. Otherwise it will produce one of the following error
  113.    codes:
  114.  
  115.       18h  =  bad line checksum
  116.       19h  =  bad CRC
  117.       1Ah  =  inter-gap timeout
  118.       1Ch  =  write error
  119.       1Dh  =  bad programming voltage
  120.  
  121.    The error codes can also occur anytime during the transfer. In
  122.    this case the programming must be aborted at once and must be
  123.    repeated completely.
  124.  
  125. 7. Finally the modem calculates a CRC over the data block and
  126.    acknowledges this with 14h in case of success or reports 19h,
  127.    respectively, if the checksum is incorrect. The calculation can
  128.    run for a maximum of 6 seconds.
  129.  
  130.  
  131.  
  132. Modem Firmware
  133. --------------
  134.  
  135. If you have been following this text closely, you certainly have
  136. been wondering how the modem recognizes the end of the firmware
  137. data. The solution is simple: apart from the actual firmware the
  138. image contains additional check and control data.
  139.  
  140. The transferred data consists entirely of small data blocks called
  141. "lines". Each line has a structure like this:
  142.  
  143.   Byte #        Content
  144.   ------------------------------------------------------
  145.   0             length of data field (n)
  146.   1 - 2         offset address of data block, MSB first
  147.   3             flag byte:  0 = normal data block
  148.                             1 = terminating data block
  149.                             2 = segment block
  150.                             3 = adress block
  151.   4 - n+3       data
  152.   n+4           checksum
  153.  
  154. The checksum is calculated by adding modulo 256 all bytes from 0
  155. up to and including n+3 and negating (one's complement) the
  156. result.
  157.  
  158. Segment blocks are always of size 2 and contain the segment
  159. address of the following data blocks, MSB first, in the data
  160. field. The first block is always a segment block. (If you do not
  161. know what segments and offsets are, you should familiarize
  162. yourself with the architecture of the 8086 CPU.) The modem saves
  163. the received "lines" at the given segment:offset address.
  164.  
  165. The terminating data block has always size 0.
  166.  
  167.  
  168.  
  169. Address Block and Loader Trick
  170. ------------------------------
  171.  
  172. Immediately before the terminating data block there is an address
  173. block of size 4, containing the segment:offset address (MSB first)
  174. at which the modem is to continue execution after the programming
  175. has succeeded. Normally, this starts power-on initialization code
  176. of the modem.
  177.  
  178. The new V.34-SDL uses this entry point to first transmit a new
  179. loader program (SDL message: "Transmitting loader..."). After the
  180. transfer, the address block of the loader program causes the newly
  181. transferred loader to be activated. It copies itself into the
  182. modem RAM, permitting the ROM to be erased completely and the
  183. transfer of the actual firmware.
  184.  
  185. Altogether, the V.34-SDL does the following:
  186. - start programming (steps 1-3)
  187. - erase ROM at C0000-FFFFF (steps 4-5)
  188. - transfer loader (about 6kB) (steps 6-7)
  189. - erase ROM at 80000-FFFFF (steps 4-5)
  190. - transfer firmware (about 312kB) (steps 6-7)
  191.  
  192.  
  193.  
  194. SDL.EXE
  195. -------
  196.  
  197. The download program features two undocumented parameters that
  198. might be useful for some applications:
  199.  
  200.      SDL /p     Skips the prompt and starts programming at once.
  201.  
  202.      SDL /u     Only seems to check the consistency of the
  203.                 firmware. /u allows for a couple of additional
  204.                 parameters. If you know your way around the
  205.                 Borland C runtime library, you are invited to find
  206.                 out their meanings...
  207.  
  208. The integrity of the firmware is checked by means of a 16-bit
  209. checksum every time SDL.EXE starts up. Thus direct patching of
  210. random ASCII data in SDL.EXE is not possible (ignoring the
  211. additional modem CRC).
  212.  
  213. Finding the firmware within SDL.EXE is rather simple. It always
  214. starts out with a segment block (02 00 00 02 ...) and ends with a
  215. terminating block (00 00 00 01 ff). In the V.34-SDL, the firmware
  216. is immediately followed by the loader which again starts with 02
  217. 00 00 02 ... and ends with 00 00 00 01 ff.
  218.  
  219. When extracting the firmware from SDL.EXE, attention must be payed
  220. to the fact that because of Intel linking technique the data is
  221. split into several segments of about 60000 bytes each, and that
  222. every segment is extended to a multiple of 16 bytes. These segment
  223. boundaries in the EXE file do NOT match boundaries between data
  224. blocks. The correct segment boundaries are only revealed by
  225. debugging since these segments do not have entries in the
  226. relocation table. There is a table of relative segment addresses
  227. followed by a table of segment lengths in the data segment.
  228.  
  229. The file addresses of the segments for the currently existing SDL
  230. releases are (no responsibility taken):
  231.  
  232.               | SDL 1994-06-17 | SDL 1994-08-17 | SDL 1994-08-25
  233.   Segment     |  Start  Length |  Start  Length |  Start  Length
  234.   ------------+----------------+----------------+----------------
  235.   Firmware #0 |  05410   ea2e  |  055b0   ea2e  |  055b0   ea2e
  236.   Firmware #1 |  13e40   ea65  |  13fe0   ea65  |  13fe0   ea65
  237.   Firmware #2 |  228b0   ea65  |  22a50   ea65  |  22a50   ea65
  238.   Firmware #3 |  31320   ea65  |  314c0   ea65  |  314c0   ea65
  239.   Firmware #4 |  3fd90   a7a6  |  3ff30   ea65  |  3ff30   ea65
  240.   Firmware #5 |                |  4e9a0   4e3c  |  4e9a0   531a
  241.   Loader      |                |  537e0   182b  |  53cc0   182b
  242.  
  243.  
  244.  
  245. Checksum
  246. --------
  247.  
  248. The 16-bit checksum used in steps (4) and (7) is not calculated
  249. from the transferred data but from all of the newly programmed
  250. memory including all unused bytes, which have the value FFh.
  251. Producing the checksum thus requires reconstructing the content of
  252. the modem ROM from the transferred data.
  253.  
  254. The algorithm depends on whether the whole ROM has been programmed
  255. or only the part starting at C0000. The calculation always works
  256. like this:
  257.  
  258.     - Initialize the checksum to FFFFh.
  259.     - Sequentially add all bytes of the range to be checked.
  260.  
  261. For the checksum from C0000 on the checked range is C0000 to
  262. F7FFFD, i.e. it is 37FFE bytes long. The calculation from 80000 on
  263. is done in two steps: First, the checksum for the range 80000-
  264. BFFFF is calculated and the result is stored at F7FFC (LSB first).
  265. The subsequent proceeding is analogous to that for a "short"
  266. checksum.
  267.  
  268. The following function is used for "adding" a single byte:
  269.  
  270.   int AddByte(int chksum, int b)
  271.   {
  272.     int  i;
  273.  
  274.     i  = (chksum ^ b);
  275.     b  = (i & 0xff)
  276.     i ^= (b << 4);
  277.     i  = (i >> 8) + ((i & 0xff) << 8);
  278.     i ^= (b << 3);
  279.     b  = (b & 0xf);
  280.     i ^= (b ^ (b << 7));
  281.  
  282.     return i;
  283.   }
  284.  
  285.  
  286.  
  287. Reading from Modem Memory
  288. -------------------------
  289.  
  290. For the purpose of porting SDL.EXE to a different platform, if
  291. there is already a reprogrammed modem at hand, the simplest way to
  292. find out the checksum is to read it directly from the modem
  293. memory. The command
  294.  
  295. AT G=ssss:oooo
  296.  
  297. displays a hexdump of the modem memory from address ssss:oooo on.
  298. The checksum is stored at F7FFE, i.e. for instance at F7FF:000E,
  299. LSB first.
  300.  
  301. <---------------
  302. -- 
  303. Christian 'naddy' Weisgerber                         naddy@mips.pfalz.de
  304.   See another pointless homepage at <URL:http://home.pages.de/~naddy/>.
  305.         -- currently reading: Timothy Zahn, Conqueror's Pride --
  306.